package pl.edu.pk.mech.kkbus.model;

import static pl.edu.pk.mech.kkbus.staticstrings.ScheduleProperty.*;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import com.google.appengine.api.datastore.Entity;
import com.google.appengine.api.datastore.Key;

public class Schedule extends Pojo implements Serializable{

	private static final long serialVersionUID = 8077255198901672231L;
	private List<String> days;
    private List<String> hours;
    private String idUser;
    
    public Schedule(){
    	this.days = new ArrayList<String>();
    	days.add("pon");
    	days.add("wto");
    	days.add("sro");
    	days.add("czw");
    	days.add("pia");
    	days.add("sob");
    	days.add("nie");
    	this.hours = new ArrayList<String>();
    	hours.add("8:00-16:00");
    	hours.add("8:00-16:00");
    	hours.add("8:00-16:00");
    	hours.add("8:00-16:00");
    	hours.add("8:00-16:00");
    	hours.add("wolne");
    	hours.add("wolne");
    }
    
    public Schedule(List<String> days, List<String> hours, String idUser){
    	this();
    	if (days == null || hours == null) {
    		this.idUser = idUser;
		}else{
	    	this.days = days;
	    	this.hours = hours;
	    	this.idUser = idUser;
		}
    }
    
    public Schedule(Entity entity){
    	this();
    	this.id = entity.getKey().getId();
    	
    	List<String> daysTemp = (List<String>) entity.getProperty(SCHEDULE_DAYS);
        List<String> hoursTemp = (List<String>) entity.getProperty(SCHEDULE_HOURS);
    	if (daysTemp == null || hoursTemp == null) {
        	this.idUser = (String) entity.getProperty(SCHEDULE_KEY_USER);
		}else{
	    	this.days = (List<String>) entity.getProperty(SCHEDULE_DAYS);
	    	this.hours = (List<String>) entity.getProperty(SCHEDULE_HOURS);
	    	this.idUser = (String) entity.getProperty(SCHEDULE_KEY_USER);
		}
    }
    
	public List<String> getDays() {
		return days;
	}
	public void setDays(List<String> days) {
		this.days = days;
	}
	public List<String> getHours() {
		return hours;
	}
	public void setHours(List<String> hours) {
		this.hours = hours;
	}

	public String getIdUser() {
		return idUser;
	}

	public void setIdUser(String idUser) {
		this.idUser = idUser;
	}

}
